// add-build-time.js
const { readFileSync, writeFileSync } = require('fs')
const { join } = require('path')
const dayjs = require('dayjs')

const buildTime = dayjs().format('YYYYMMDD')
const indexPath = join(__dirname, 'dist', 'index.html')
let html = readFileSync(indexPath, 'utf-8')
html = html.replace(/<title>(.*?)<\/title>/, `<title>$1-V${buildTime}</title>`)
writeFileSync(indexPath, html)